Hybrid RC/crystal oscillator

ABSTRACT

An oscillator includes a tunable oscillator, a phase detector circuit communicatively coupled with an output of the tunable oscillator and an input to the oscillator, and an oscillator controller circuit configured to adjust frequency of the tunable oscillator based upon phase detection between output of the tunable oscillator and output of an external resonant element received at the input to the oscillator.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. application Ser. No.15/491,803 filed on Apr. 19, 2017, which is incorporated herein in itsentirety.

TECHNICAL FIELD

The present disclosure relates to integrated circuit devices, inparticular, processors and microcontrollers with integrated oscillators.

BACKGROUND

Microprocessors and in particular microcontrollers require oscillatorswhich are often integrated within the device. A frequency of theoscillator is generally determined by either an internal or an externalcomponent. Internal or external components are usually resistorcapacitor (RC) elements wherein crystals are generally provided only asexternal components. These external components are coupled with theintegrated circuit device through external pins. Start-up of anoscillator is often critical and requires defined signals andconditions. See also “Mid-range MCU reference Manual”, DS31002A, 1997available from the Assignee of the present application, MicrochipTechnology Inc., which is hereby incorporated by reference in itsentirety.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is an illustration of an example embodiment of a hybridRC/crystal oscillator, in accordance with embodiments of the presentdisclosure;

FIG. 2 is an illustration of another example embodiment of a hybridRC/crystal oscillator, in accordance with embodiments of the presentdisclosure;

FIG. 3 illustrates waveforms measuring typical OSCIN/OSCOUT signals,according to embodiments of the present disclosure;

FIG. 4 illustrates an equivalent circuit model of the oscillators, inaccordance with embodiments of the present disclosure;

FIG. 5 illustrates operation and response of the circuit mode, inaccordance with embodiments of the present disclosure; and

FIGS. 6 and 7 illustrate driving a physical crystal at variousfrequencies close to resonance, according to embodiments of the presentdisclosure.

SUMMARY

Embodiments of the present disclosure include an oscillator or anoscillator circuit. The oscillator may include a tunable oscillatorcommunicatively coupled with a first pin. The oscillator may include aphase detector circuit communicatively coupled with an output of thetunable oscillator and an input to the oscillator. The oscillator mayinclude an oscillator controller circuit configured to adjust frequencyof the tunable oscillator based upon phase detection between output ofthe tunable oscillator and output of an external resonant element, suchas a crystal, received at the input to the oscillator. In combinationwith any of the above embodiments, the oscillator may further include asecond pin communicatively coupled to input to the oscillator, whereinthe tunable oscillator is configured to issue output through the firstpin, and the phase detector circuit is configured to receive input tothe oscillator through the second pin. In combination with any suitableones of the above embodiments, the tunable oscillator is configured toissue output through the first pin, and the phase detector circuit isconfigured to receive input to the oscillator through the same firstpin. In combination with any suitable ones of the above embodiments, thetunable oscillator is configured to issue output through a drivercircuit at the first pin, the phase detector circuit is configured toreceive input to the oscillator through the first pin, and the drivercircuit is configured to issue the output at the first pin as a currentsource and to detect voltage on the first pin as the input to theoscillator. In combination with any suitable ones of the aboveembodiments, oscillator controller circuit is further configured tooutput a crystal oscillator status based upon input to the oscillator.In combination with any suitable ones of the above embodiments, theoscillator controller circuit is further configured to maintain outputof the tunable oscillator based upon a determination that an externalresonant element has failed to generate a usable input to theoscillator. In combination with any suitable ones of the aboveembodiments, the oscillator controller circuit is further configured toadjust output of the tunable oscillator based upon a determination thata phase lock has been achieved between output of the tunable oscillatorand the input to the oscillator. In combination with any suitable onesof the above embodiments, the oscillator controller circuit is furtherconfigured to maintain output of the tunable oscillator based upon adetermination that a phase lock between output of the tunable oscillatorand the input to the oscillator has been lost. In combination with anysuitable ones of the above embodiments, the oscillator further includesa frequency multiplier circuit coupled between the tunable oscillatorand the first pin, wherein an output of the frequency multiplier iscoupled with the phase detector circuit to provide the output of thetunable oscillator. In combination with any of the above embodiments,the first pin may be an external pin, as an external interface for apackage with the rest of the oscillator. In combination with any of theabove embodiments, the second pin may be an external pin, as an externalinterface for a package with the rest of the oscillator. In combinationwith any of the above embodiments, the oscillator may include a secondexternal pin coupled with an input of a receiver, wherein the first andsecond external pins are coupled with a first and second terminal of anexternal crystal, respectively. In combination with any of the aboveembodiments, an input of the receiver may be coupled with the firstexternal pin, wherein the first external pin is coupled with a firstterminal of an external crystal, wherein a second terminal of theexternal crystal is coupled with ground. In combination with any of theabove embodiments, the tunable oscillator may be an RC oscillator. Incombination with any of the above embodiments, the oscillator controllermay be a slow PI controller. In combination with any of the aboveembodiments, the phase detector circuit may be formed by an XOR gate. Incombination with any of the above embodiments, a status may includesearching, locked, or lost. In combination with any of the aboveembodiments, the phase detector circuit may include a PLL circuit. Incombination with any of the above embodiments, an accumulator may beincluded to add a first constant to a sum when the output of the XORgate is one. In combination with any of the above embodiments, theaccumulator may be configured to subtract a second constant from the sumwhen the output of the XOR gate is 0. In combination with any of theabove embodiments, the constants may be equal. In combination with anyof the above embodiments, equilibrium is may be reached at 90-degreephase difference when the constants are equal. In combination with anyof the above embodiments, the constants may be different andsteady-state equilibrium values are at or below 90 degrees. Incombination with any of the above embodiments, the tunable oscillatormay be a primary resonant source for the oscillator and the externalresonant element may be configured to act as a sensor for theoscillator. In combination with any of the above embodiments, thetunable oscillator may be communicatively coupled with the first pinthrough a driver. In combination with any of the above embodiments, thephase detector circuit may be coupled to the input to the oscillatorthrough a receiver circuit. In combination with any of the aboveembodiments, the second pin may be coupled to the receiver.

Embodiments of the present disclosure may include a microcontroller,including a processor, one or more peripheral circuits, and anoscillator implemented by any of the above embodiments. The oscillatormay be configured to provide an oscillation signal to one or more of theperipheral circuits.

Embodiments of the present disclosure may include a system including asemiconductor device, comprising a first external pin and an internaloscillator, wherein the internal oscillator is implemented by any of theabove embodiments. The system may also include an external resonantelement coupled to the semiconductor device at least through the firstexternal pin.

Embodiments of the present disclosure may include systems, packages,semiconductor devices, microcontrollers, systems, dies, chips, or otherdevices that include any of the oscillators of the above embodiments.

Embodiments of the present disclosure may include methods performed byany of the oscillators, systems, packages, semiconductor devices,microcontrollers, systems, dies, chips, or other devices that includeany of the oscillators of the above embodiments.

DETAILED DESCRIPTION

FIG. 1 is an illustration of an example embodiment of a hybridRC/crystal oscillator 100, in accordance with embodiments of the presentdisclosure. Oscillator 100 may be implemented within an electronicdevice, such as a microcontroller, semiconductor chip, processor, orperipheral. For example, oscillator 100 may be implemented within a PICmicrocontroller, manufactured by the Assignee of the presentapplication.

Some microcontrollers may have options for both an internal RC-basedoscillator and an external crystal or oscillator. External oscillatorsmay add cost, take longer to start-up, use up device pins, and may hurtreliability as an external, separate component. However, externaloscillators may be more accurate, which may be needed in someapplications requiring precise clocks. Oscillator 100 may augmentadvantages of an internal RC by implementing a hybrid clock source. Inone embodiment, such a source may include a tunable internal RC and anexternal crystal as a supplementary clock source. In another embodiment,the external crystal might be needed only as a reference sensor ratherthan as a primary resonant element. The oscillator may retain thereliability and quick-startup of the internal RC oscillator. This mayhave other advantages, such as frequency flexibility, higher signalintegrity, and possible use of a single pin, rather than two pins, toconnect to the external crystal, according to various embodiments.

Oscillator 100 may include an OSCOUT output and an OSCIN input to anexternal crystal 112, denoted as X1. The OSCOUT and OSCIN may beconnected across two terminals of crystal 112. Each terminal of crystal112 may be connected to a respective capacitor 110, 112, denoted as C1and C2. These capacitors may in turn be connected to ground. Crystal 112may include a quartz crystal, piezoelectric crystal, piezoelectriccrystal resonator, or any other resonant element.

The values of C1 and C2 may be selected so as to match the impedance ofthe driving pins and crystal 112. Selection of the values may be madeaccording to the publication “Basic PlCmicro Oscillator Design”,Application Note AN849, published by the assignee of the presentApplication. The crystal may appear to the remainder of the circuit tobe inductive.

In one embodiment, the elements to the right of OSCOUT and OSCIN may beconsidered external components, and the elements to the left of OSCOUTand OSCIN may be considered internal components. The external versusinternal nature may be made with respect to, for example, packaging ofan integrated circuit device. Such an integrated circuit device mightinclude a microcontroller, processor, peripheral, chip, package, orother suitable device. OSCOUT and OSCIN may be pins for such a package.

Oscillator 100 may include an OSCTUN input 102. OSCTUN may stand for“oscillator tuning.” OSCTUN 102 may be implemented as an input tooscillator 100 so that oscillator 100 may receive working parametersfrom the system in which oscillator 100 is implemented. For example,OSCTUN 102 may be implemented as a register. If oscillator 100 includesa fast RC (FRC) oscillator circuit, then the register may be availableso that adjustment to parameters of operation of the fast RC circuit canbe made. Oscillator 100 might be calibrated in a factory or duringproduction of oscillator 100. Thus, OSCTUN 102 might be set by aproduction machine making or configuring oscillator 100. However, OSCTUN102 can be adjusted during, for example, execution of oscillator 100.

Oscillator 100 may include a tunable FRC oscillator 104. Tunable FRCoscillator 104 may receive its operational parameters from OSCTUN 102.OSCTUN 102 may provide a coarse adjustment to tunable FRC oscillator104. In one embodiment, crystal 112 may provide users the ability toreplace input from OSCTUN 102. Tunable FRC oscillator 104 frequency maybe adjusted using input from OSCTUN 102 or by crystal 112. The frequencyof tunable FRC oscillator 104 may be adjusted with a range, for example,of plus or minus 12%. OSCTUN 102 might be implemented in, for example,five bits. Tunable FRC oscillator 104 may be implemented by any suitablecombination of analog circuitry, digital circuitry, or a combinationthereof.

In one embodiment, crystal 112 may operate as a reference sensor foroscillator 100, rather than a primary resonant element. Accordingly,oscillator 100 may retain the reliability and fast start-up timeassociated with use of tunable FRC oscillator 104 as the primaryresonant element. Crystal 112 may supplement operation of tunable FRCoscillator 104 to make adjustments. For example, the accuracy offrequency of internal RC oscillators is insufficient over the fulltemperature operational range of oscillator 100. A crystal gradeoscillator, such as one implementation of crystal 112, is typicallysufficiently accurate over such operational ranges with respect totemperature.

Tunable FRC oscillator 104 may act as the critical or baseline clockelement of oscillator 100. Tunable FRC oscillator 104 may be able togenerate a clock signal that, while not as accurate as crystal 112 underideal operational circumstances, becomes valid more quickly than that ofcrystal 112 during start-up. Accordingly, the output of oscillator 100may depend upon tunable FRC oscillator 104 at start-up. However, aftercrystal 112 is started up (with input from tunable FRC oscillator 104)and its output is locked and manipulated (through PLL, etc.), its signalmay be used to fine-tune or adjust the operation of tunable FRCoscillator 104. Similarly, during any failures or inconsistencies ofcrystal 112, tunable FRC oscillator 104 may continue to provide abaseline output that, while not ideal, is sufficient while crystal 112is temporarily unavailable to adjust and fine-tune the output of tunableFRC oscillator 104. When any interference, start-up, loss of lock, orother error of crystal 112 is encountered, the signal generatedinternally by tunable FRC oscillator 104 may be used without adjustmentfrom crystal 112. Thus, the signal generated by crystal 112 might notitself be used as the output of oscillator 100. Instead, the signalgenerated by crystal 112, when available and reliable, may be used as asensor to adjust the signal generated by tunable FR oscillator 104.

The frequency of crystal 112 may be selected so as to match the desiredfrequency of tunable FRC oscillator 104. Crystal 112 may be driven withthe signal from tunable FRC oscillator 104 so as to generate output fromcrystal 112, against which the output of tunable FRC oscillator 104 iscompared. The phases of the two signals may be compared and thefrequency of tunable FRC oscillator 104 may be adjusted to match that ofcrystal 112, producing a stable equilibrium known as phase lock. Duringthis equilibrium, typically, the signals should be within 45-60 degreesof phase. Typically, the signals should be within 45-60 degrees ofphase. If crystal 112 is overdriven, it might drive at a harmonic of itsbase frequency, also known as an overtone. But driven properly, itsfrequency matches the FRC desired value relative to phase difference,shown in FIG. 6 and discussed below, may drive phase detection. Theamplitude might need only be sufficient to get a valid signal as input.Phase comparison, performed by a phase detector, may require sufficientamplitude from both signals and produces a signal that is a monotonicfunction of relative phase difference between two signals.

Furthermore, oscillator 100 may include a frequency multiplier 106.Frequency multiplier 106 may be implemented by any suitable combinationof analog circuitry, digital circuitry, or a combination thereof.Frequency multiplier 106 may be implemented as an M/N type frequencymultiplier. In such an implementation, frequency multiplier 106 mayinclude a phase-locked loop (PLL) multiplier “M” followed by a clockdivider “N” such that an I/O driver 108 may issue a signal with asubmultiple of the PLL multiplier. The signal may be a submultiple ofthe system clock frequency if M=1. The output frequency may be given byf1=M/N*f0, wherein f1 is the frequency of the signal applied to the I/Opin and f0 is the input frequency, the frequency of the FRC module.

Oscillator 100 may include an I/O driver 108, implemented by anysuitable combination of analog circuitry, digital circuitry, or acombination thereof. I/O driver 108 may be implemented by a series ofone or more buffered or unbuffered inverters. I/O driver 108 maygenerate, from the signal generated by tunable FRC oscillator 104 asadjusted by frequency multiplier 106, a square wave signal and apply itto crystal 112. I/O driver 108 may output the square wave signal throughthe OSCOUT pin. The square wave signal, as formatted by I/O driver 108,may cause resonant signals to be generated by crystal 112. I/O driver108 and receiver 116 may be implemented as a voltage-limited currentsource or sink, driven with positive and negative current for each halfof the source clock square wave, rather than a voltage source, toimprove power dissipation characteristics.

In one embodiment, the OSCIN pin may be attached to the other end ofcrystal 112. In another embodiment, as shown in FIG. 2, the OSCIN pinmight be attached to crystal 112 in that the OSCOUT pin and the OSCINpin are the same pin. The OSCIN pin may feed a signal from the other endof crystal 112 to a receiver 116.

Receiver 116 may be implemented by any suitable combination of analogcircuitry, digital circuitry, or a combination thereof. Receiver 116 maybe implemented by a series of one or more buffered or unbufferedinverters. Receiver 116 may be configured to convert the resultingsignal into a digital waveform. Such a signal may be a square wave.Resonance of crystal 112 may produce a band-pass filter. Such aband-pass filter may reject all or nearly all harmonics of the drivingwaveform received by crystal 112 except at the resonant frequency. Thus,the result may be a sine wave which, after receipt and conversion byreceiver 116, may be digitized into a square wave.

Oscillator 100 may include a phase detector 118. Phase detector 118 maybe implemented by any suitable combination of analog circuitry, digitalcircuitry, or a combination thereof. Phase detector 118 may accept asinput the signal that was generated by tunable FRC oscillator 104 andmodified by frequency multiplier 106. Phase detector may also accept asinput the signal that was generated by receiver 116. In one embodiment,these inputs may include input and output square waves. Phase detector118 may include, for example, an XOR gate followed by an accumulator.The accumulator may perform an accumulation, such as adding apredetermined amount (K1) to a sum when the output of the XOR gate is alogical one. Furthermore, the accumulation may subtract anotherpredetermined amount (K2) from the some when the output of the XOR gateis a logical zero. Accordingly, a steady-state equilibrium may bereached, dependent on the values K1 and K2. If K1 and K2 are equal, thenequilibrium is reached at 90° phase difference. Adjusting K1 and K2 mayallow other steady-state equilibrium values above or below 90°.

Oscillator 100 may include an oscillator controller 120. Oscillatorcontroller 120 may be implemented by any suitable combination of analogcircuitry, digital circuitry, or a combination thereof. Oscillatorcontroller 120 may be configured to control PLL operation. The PLL maybe analog or digital. Oscillator controller 120 may be implemented as aproportional-integral (PI) controller with independently controllable“P” and “I” gains to control the bandwidth and phase margin of thephase-locked loop. Such a phase-locked loop may be a relatively slowbandwidth (typically 10-1000 Hz) depending on design tradeoffs betweenresponse time and jitter/stability issues. Oscillator controller 120 mayprovide fine adjustment to tunable FRC oscillator 104. Operation of animplementation of oscillator controller 120 may be given, in a digitalimplementation, according to an integrator defined byint[n]=int[n−1]+Ki*x[n]. Output may be given by out[n]=int[n]+Kp*x[n].The term x[n] may specify input error at timestep n, wherein the [n]notation may apply to any signal or digital value. Ki may specify anintegral gain and Kp may specify a proportional gain. Such animplementation may use multipliers, which might be expensive in terms ofcircuitry or die space if implemented to execute in a single clockcycle. Accordingly, oscillator control 120 may be improved by reducing abit width of constants Kp or Ki, such as using 4-6 bits instead of 16bits. Furthermore, oscillator control 120 may be improved to reducerequired area and cost by implementing multiplication operations with aserial shift-and-add circuit that takes several clock cycles tocomplete. The frequency of tunable FRC oscillator 104 may be adjusted soas to track the crystal resonance.

As a result, tunable FRC oscillator 104 may provide a fast startup andhigh-frequency stability with respect to frequency output. Crystal 112may be used only to provide fine adjustment to tunable FRC oscillator104. The fine adjustment provided from crystal 112 through oscillatorcontroller 120 may be, at its full-scale gain, the equivalent range offour to eight counts of coarse adjustment from OSCTUN. The frequencyrange may be restricted such that oscillator 100 does not oscillate atovertones. Oscillator 200, described below, may lock according to animpedance phase rather than voltage response. The impedance response, asopposed to the voltage response, may be used by the PLL by comparing asignal representative of the output current (at the OSCIN/OSCOUT pin) tothe received input voltage (at the OSCIN/OSCOUT pin).

Oscillator controller 120 may also include a state machine. The statemachine may track whether receiver 116 has detected an input signal. Ifreceiver 116 has not detected an input, oscillator controller 120 maycause a slow frequency sweep until phase lock is detected. Thisoperation may extend the pull-in range of oscillator 100 and alsoprovides a way to detect a crystal oscillator status, which may beissued as XT_STATUS 122. States in the state machine may be representedin XT_STATUS 122, such as searching for a frequency (and thus no inputfrom receiver 116 or input from receiver 116 and the PLL is operating),locked frequency (and thus input from receiver 116 and subsequent lockedfrequency from the PLL), or lock lost (and thus dropped input fromreceiver 116 or other disparate input).

Oscillator controller may operate at relatively slow rate, such as lessthan 1 kHz. In response to fine adjustment from oscillator controller120, tunable FRC oscillator 104 may adjust its output frequency orphase.

In one embodiment, if crystal 112 has failed to start, tunable FRCoscillator 104 may maintain a nominal frequency. In another embodiment,if crystal 112 starts initially but later fails, tunable FRC oscillator104 may maintain a nominal frequency. Crystal 112 may fail in such a wayif, for example, there is an open or short circuit, or temperature,humidity, interference, or other environmental factors cause gain to bereduced below a detectable level.

FIG. 2 illustrates another example embodiment of an oscillator,according to embodiments of the present disclosure. Oscillator 200 maybe implemented similarly to oscillator 100. However, in one embodimentI/O driver 208 and receiver 216 may be implemented as a currentsource/sink driver. In a further embodiment, I/O driver 208 and receiver216 might be implemented within a same circuit or element. In another,further embodiment, a single pin might be used to interface crystal 112with the elements on left-side of the figure, such elements on theleft-side of the figure starting with the pin OSCOUT implementedinternally within a microcontroller, processor, package, semiconductordevice, or other device. In one embodiment, voltage on the OSCOUT pinmay be used as a receiver signal. In another embodiment, phase detector118 may take advantage of the phase shift between driver current anddriver voltage caused by the resonant element.

Oscillator 200 and oscillator 100 may also be implemented with respectto on-chip resonant oscillators wherein crystal 112 is implemented assilicon inductor-capacitor circuits, or co-packaged dual-diemicroelectromechanical system oscillators or quartz crystal devices. Inthese embodiments, the implementation of crystal 112 may still beexternal to tunable FRC oscillator 104 even though all circuit elementsare internal to the overall package.

FIG. 3 illustrates waveforms measuring typical OSCIN/OSCOUT signals,according to embodiments of the present disclosure. The view of FIG. 3may be from an oscilloscope. A first graph trace may show OSCIN inputinto crystal 112, while a second graph trace may show an OSCOUT outputfrom crystal 112. The graph of FIG. 3 may have been created using an8.00 MHz crystal 112 and two 33 pF loading capacitors 110, 114. Graph 1may be OSCOUT, and graph 2 may be OSCIN. The two signals may beapproximately 180° apart. When added to the 180° phase shift ofoscillator driver 208, this configuration meets the Barkhausen stabilitycondition for oscillation, wherein total phase shift must be a multipleof 360°, with a loop gain of 1.

FIG. 4 illustrates an equivalent circuit model of the oscillators, inaccordance with embodiments of the present disclosure. In particular,crystal 112 may be modeled approximately by a series RLC combinationwith parasitic capacitance Co. For the instance of crystal 112 from FIG.3, the values of the lumped-parameter equivalent circuit were determinedas Co=4.24 pF, Cs=16.5 fF, Ls=10.6 mH, and Rs=9Ω. The frequency responseof this circuit is shown below in FIG. 5 for load capacitors of 15 pF,20 pF, and 33 pF. This models the OSCOUT source as a perfect sine waveat a given frequency, and the load circuit of the crystal equivalentcircuit along with the two parallel load capacitors. The four subgraphsare, in order:

-   -   Transfer function magnitude (OSCIN/OSCOUT), in decibels    -   Transfer function phase shift, in degrees    -   OSCIN load admittance magnitude (output current divided by        output voltage), A/V    -   OSCIN load admittance phase, in degrees

The series resonance (peaks in the response magnitude) and parallelresonances (notches in the response magnitude) are both around 12.0 MHz.The series resonant frequency has a small sensitivity to loadcapacitance. The parallel resonance in the transfer function hasvirtually no dependence on load capacitance but represents a notchfilter response with low signal level.

Typical operation of a traditional oscillator is at the point where thetransfer function phase is close to ±180° and the loop gain is 1.0. Thisrepresents a frequency that is slightly greater than that of the seriesresonant peak.

Accordingly, the phase detector approach according to variousembodiments of oscillators 100, 200 may be most effective when thecircuit response has high phase sensitivity. Such high phase sensitivitymay be highest at approximately 90° phase shift. However, this may alsobe the point at which the load seen by the source has the highestadmittance and therefore may require the highest current draw for agiven voltage magnitude. A 90° phase shift represents pure reactivepower, and therefore it is theoretically possible to produce thisoscillation with very little net power if suitable storage inductance orcapacitance is available and the output driver uses energy-recoverytechniques. If this causes overdriving the crystal or excessive powerdissipation, several mitigation approaches can be used. First, theequilibrium phase can be adjusted to be at a different point e.g. 45° or135°. Second, the driver gain might be dynamically adjusted to reducesignal magnitude. Third, a current source output might be used.

FIGS. 6 and 7 illustrate driving an actual crystal at variousfrequencies close to resonance, according to embodiments of the presentdisclosure. These figures can be used for determining sensitivity ofphase and amplitude response to changes in frequency. A signal generatorwas used to apply a square wave of known frequency.

FIG. 6 shows the voltage response at various drive frequencies. Theoscilloscope used to generate FIG. 6 was triggered by frequencygenerator's SYNC signal, at time t=0. The zero-crossing time changes asa function of frequency, indicating a phase shift that is sensitive tosmall changes in frequency. At maximum resonance, the phase shift isabout 90°, as can be seen in FIG. 7. The square wave signal degrades toa waveform with sags near the zero crossings of the voltage responsepresumably at the point of highest current draw. Because the crystal hassuch a narrow bandpass effect, the output may still appear sinusoidal.The gain is roughly in the 4-8 range (12-18 dB).

A hybrid approach as described in this disclosure and implemented asoscillators 100, 200 may deliver the advantages of both internal FRCoscillator and the accuracy of an external crystal. These may includefast startup times of the FRC oscillator; stability and reliability ofthe FRC oscillator; accuracy of the crystal oscillator; flexibility inselecting crystal oscillator frequencies, using a clockmultiplier/divider; fault-tolerance; very low impact of oscillatorstartup failure or failure at runtime; seamless and inherent fallback toFRC oscillation; fault-detection possible (detect low signal amplitudeor too much variation in phase detector output) to provide feedback tofirmware; low control bandwidth requirements of the outer PLL (the FRCoscillator controls moderate-to-high-frequency jitter performance, andthe outer PLL is used only for low-frequency correction of theoscillator frequency to meet accuracy requirements); sensitivity toexternal circuit response phase, rather than loop gain (this may makethe oscillation frequency more stable over temperature, since changes inoutput driver gain would not affect the output of the phase detector);additional flexibility for driver output amplitude, to decrease powerdissipation; possible use of energy recovery (90° phase shift representspure reactive power) to decrease power dissipation; and possible use ofonly one pin for output and input, wherein current is applied andvoltage is sensed.

Although example embodiments have been described above, other variationsand embodiments may be made from this disclosure without departing fromthe spirit and scope of these embodiments.

The invention claimed is:
 1. An oscillator, comprising: a tunableoscillator communicatively coupled with a first pin, the tunableoscillator configured to drive an output signal through the first pin toan external resonant element; a phase detector circuit communicativelycoupled with an output of the tunable oscillator and an input to theoscillator; and an oscillator controller circuit configured to adjustfrequency of the tunable oscillator based upon phase detection betweenoutput of the tunable oscillator and an output of the external resonantelement received at the input to the oscillator, wherein the oscillatorcontroller circuit is configured to use the output of the externalresonant element to adjust frequency of the tunable oscillator duringthe entire operation of the tunable oscillator.
 2. The oscillator ofclaim 1, further comprising a second pin communicatively coupled toinput to the oscillator, wherein: the phase detector circuit isconfigured to receive input to the oscillator through the second pin. 3.The oscillator of claim 1, wherein the phase detector circuit isconfigured to receive input to the oscillator through the first pin. 4.The oscillator of claim 1, wherein: the tunable oscillator is configuredto issue output through a driver circuit at the first pin; and the phasedetector circuit is configured to receive input to the oscillatorthrough the first pin; the driver circuit is configured to issue theoutput at the first pin as a current source and to detect voltage on thefirst pin as the input to the oscillator.
 5. The oscillator of claim 1,wherein the oscillator controller circuit is further configured tooutput a crystal oscillator status based upon input to the oscillator,wherein the status is configured to denote whether the oscillator issearching for a frequency, whether the oscillator has a lockedfrequency, and whether the oscillator has lost a locked frequency. 6.The oscillator of claim 1, wherein the oscillator controller circuit isfurther configured to maintain output of the tunable oscillator basedupon a determination that an external resonant element has failed togenerate a usable input to the oscillator.
 7. The oscillator of claim 1,wherein the oscillator controller circuit is further configured toadjust output of the tunable oscillator based upon a determination thata phase lock has been achieved between output of the tunable oscillatorand the input to the oscillator.
 8. The oscillator of claim 1, whereinthe oscillator controller circuit is further configured to maintainoutput of the tunable oscillator based upon a determination that a phaselock between output of the tunable oscillator and the input to theoscillator has been lost.
 9. The oscillator of claim 1, furthercomprising a frequency multiplier circuit coupled between the tunableoscillator and the first pin, wherein an output of the frequencymultiplier is coupled with the phase detector circuit to provide theoutput of the tunable oscillator.
 10. A microcontroller, comprising: aprocessor; one or more peripheral circuits; and an oscillator,comprising: a tunable oscillator communicatively coupled with a firstpin, the tunable oscillator configured to drive an output signal throughthe first pin to an external resonant element and to one or more of theperipheral circuits; a phase detector circuit communicatively coupledwith an output of the tunable oscillator and an input to the oscillator;and an oscillator controller circuit configured to adjust frequency ofthe tunable oscillator based upon phase detection between output of thetunable oscillator and output of the external resonant element receivedat the input to the oscillator, wherein the oscillator controllercircuit is configured to use the output of the external resonant elementto adjust frequency of the tunable oscillator during the entireoperation of the tunable oscillator.
 11. The microcontroller of claim10, further comprising a second pin communicatively coupled to input tothe oscillator, wherein: the phase detector circuit is configured toreceive input to the oscillator through the second pin.
 12. The phasedetector circuit is configured to receive input to the oscillatorthrough the first pin.
 13. The microcontroller of claim 10, wherein: thetunable oscillator is configured to issue output through a drivercircuit at the first pin; and the phase detector circuit is configuredto receive input to the oscillator through the first pin; the drivercircuit is configured to issue the output at the first pin as a currentsource and to detect voltage on the first pin as the input to theoscillator.
 14. The microcontroller of claim 10, wherein the oscillatorcontroller circuit is further configured to output a crystal oscillatorstatus based upon input to the oscillator, wherein the status isconfigured to denote whether the oscillator is searching for afrequency, whether the oscillator has a locked frequency, and whetherthe oscillator has lost a locked frequency.
 15. The microcontroller ofclaim 10, wherein the oscillator controller circuit is furtherconfigured to maintain output of the tunable oscillator based upon adetermination that an external resonant element has failed to generate ausable input to the oscillator.
 16. The microcontroller of claim 10,wherein the oscillator controller circuit is further configured toadjust output of the tunable oscillator based upon a determination thata phase lock has been achieved between output of the tunable oscillatorand the input to the oscillator.
 17. The microcontroller of claim 10,wherein the oscillator controller circuit is further configured tomaintain output of the tunable oscillator based upon a determinationthat a phase lock between output of the tunable oscillator and the inputto the oscillator has been lost.
 18. The microcontroller of claim 10,further comprising a frequency multiplier circuit coupled between thetunable oscillator and the first pin, wherein an output of the frequencymultiplier is coupled with the phase detector circuit to provide theoutput of the tunable oscillator.
 19. A system, comprising: asemiconductor device, comprising a first external pin and an internaloscillator; and an external resonant element coupled to thesemiconductor device at least through the first external pin; whereinthe internal oscillator comprises: a tunable oscillator communicativelycoupled with the first pin and configured to provide an oscillationsignal to a portion of the semiconductor device; a phase detectorcircuit communicatively coupled with an output of the tunable oscillatorand an input to the internal oscillator; and an oscillator controllercircuit configured to adjust frequency of the tunable oscillator basedupon phase detection between output of the tunable oscillator and outputof the external resonant element received at the input to the internaloscillator, wherein the oscillator controller circuit is configured touse the output of the external resonant element to adjust frequency ofthe tunable oscillator during the entire operation of the tunableoscillator.
 20. A method, comprising: with a tunable oscillatorcommunicatively coupled with a first pin of an oscillator, driving anoutput signal through the first pin to an external resonant element;detecting phases with a phase detector circuit communicatively coupledwith an output of the tunable oscillator and an input to the internaloscillator; and with an oscillator controller circuit, adjustingfrequency of the tunable oscillator based upon phase detection betweenoutput of the tunable oscillator and output of the external resonantelement received at the input to the internal oscillator, includingusing the output of the external resonant element to adjust frequency ofthe tunable oscillator md during the entire operation of the tunableoscillator.